package handlers

import (
	"cak/models"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Add(c *gin.Context) {
	statuc := c.PostForm("status")
	name := c.PostForm("name")
	address := c.PostForm("address")
	ck := models.Ck{
		Status:  statuc,
		Name:    name,
		Address: address,
	}
	models.DB.Create(&ck)
	if statuc == "" || name == "" || address == "" {
		c.JSON(http.StatusOK, gin.H{
			"code": 500,
			"msg":  "字段为空",
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "添加成功",
		"data": ck,
	})
	return
}
